<?php 
$profileId=$_SESSION['profileid'];
if(isset($_GET['date3']))
{
	$startDate = $_GET['date3'];
} else {
	$tanggalmulai= date('Y-m-d', strtotime('-1 month'));
	$startDate = $tanggalmulai;
}
if(isset($_GET['date4']))
{
	$endDate = $_GET['date4'];
} else {
$endDate = date('Y-m-d');
}
if(isset($_GET['dimension']))
{
	$dimension = $_GET['dimension'];
} else {
$dimension = "ga:date";
}
?>
<h2>Recency</h2>
<div class = "row" >
<?php
$RParams = array(
      'dimensions' => 'ga:daysSinceLastSession'
      
      
		);
$resultsR = $analytics->data_ga->get(
       'ga:' . $profileId,
       $startDate,
       $endDate,
	   'ga:users',
       $RParams
	   );
	   
$rlength = count($resultsR->getRows());

if (count($resultsR->getRows()) > 0) {
    $newr = array(); 
	foreach ($resultsR->getRows() as $r)
      {
		$newr[] =  $r[0];
       
       //echo $total;
      }
    
	
	
	$hasil = array_sum($newr)/$rlength;
	echo "<p class='bg-primary' align = 'center'>Rentang waktu pengunjung dalam mengakses website adalah ".$hasil." Hari</p>";
    } else {
      echo '<p>No results found.</p>';
    }


?>
</div>